//
//  LMToolBar.swift
//  WeiBo
//
//  Created by Li MAc on 2018/12/1.
//  Copyright © 2018 Li MAc. All rights reserved.
//

import UIKit

class LMToolBar: UIView {

    @IBOutlet weak var retweetedBut: UIButton!
    
    @IBOutlet weak var commentBut: UIButton!
    
    @IBOutlet weak var likeBut: UIButton!
    
    
    var ToolBarModel:WBStatusViewModel? {
        didSet{
            let rep = CountString(count: ToolBarModel?.status.reposts_count ?? 0, moren: "转发")

            let  com = CountString(count: ToolBarModel?.status.comments_count ?? 0, moren: "评论")

            let like = CountString(count: ToolBarModel?.status.attitudes_count ?? 0, moren: "赞")
            
            retweetedBut.setTitle(rep, for: [])
            commentBut.setTitle(com, for: [])
            likeBut.setTitle(like, for: [])
            
            
            
//            retweetedBut.setTitle("\(String(describing: ToolBarModel?.status.user!.comments_count ))", for: [])
//
//
//
//            commentBut.setTitle("\(String(describing: ToolBarModel?.status.comments_count))", for: [])
//
//            likeBut.setTitle("\(String(describing: ToolBarModel?.status.attitudes_count))", for: [])
            
        }
        
    }
    
    private func CountString(count:Int,moren:String) -> String {
        if count == 0 {
            return moren
        }
        if count < 1000 {
            //实际数值
            return count.description
        }
        return String(format: "%0.02f万", count/10000)
    }
   

}
